package main
import (
	"fmt"
)

type SalaryCalculator interface {
    CalculateSalary() int
}

type Permanenr struct {
    empId       int
    basicpay    int
    pf          int
}
type Contract struct {
    empId int
    basicpay int
}
//salary of permanent employee is sum of basic pay and pf
func (p Permanenr) CalculateSalary() int {
    return p.basicpay + p.pf
}
//salary of contract employee is the basic pay alone
func (c Contract) CalculateSalary() int {
    return c.basicpay
}

func totalExpense(s []SalaryCalculator){
    expense := 0
    for _, v := range s {
        expense += v.CalculateSalary()
    }
    fmt.Printf("Total Expense Per Month $%d", expense)
}

// 18.接口的实际用途 根据公司员工的个人薪资，计算公司的总支出。
func main(){
    pemp1 := Permanenr{1, 5000, 20}
    pemp2 := Permanenr{2, 6000, 33}
    cemp1 := Contract{3, 8888}
    employees := []SalaryCalculator{pemp1, pemp2, cemp1}
    totalExpense(employees)


}